import logging

logger = logging.getLogger(__name__)
# handler
# 添加文件名、函数名、行号、日志级别、时间等信息
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# 添加控制台输出
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
ch.setFormatter(formatter)
logger.addHandler(ch)
# 添加文件输出
fh = logging.FileHandler('dagent.log')
fh.setLevel(logging.DEBUG)
fh.setFormatter(formatter)
logger.addHandler(fh)
logger.setLevel(logging.DEBUG)
# logger.debug('debug message')


def log_info(text):
    logger.info(text)
def log_debug(text):
    logger.debug(text)
def log_error(text):
    logger.error(text)
